#!/usr/bin/python
#coding=utf-8
'''
    4.8 排列组合的迭代
'''

# 接受一个集合并产生一个元祖序列
items = ['a', 'b', 'c']
from itertools import permutations
for p in permutations(items):
    print(p)

# 得到指定长度的所有排列
for p in permutations(items, 2):
    print(p)

# 得到输入集合中元素的所有的组合
from itertools import combinations
for c in combinations(items, 3):
    print(c)

for c in combinations(items, 2):
    print(c)

for c in combinations(items, 1):
    print(c)

from itertools import combinations_with_replacement
for c in combinations_with_replacement(items, 3):
    print(c)

# 当我们碰到看上去有些复杂的
# 迭代问题时，最好可以先去看看 itertools 模块